/**
 * Project Name:emm-website
 * File Name:NeedReceicerefundExportServiceImpl.java
 * Package Name:com.emm.yixun.website.service.marketing
 * Date:2017年11月9日下午1:51:21
*/

package com.emm.yixun.website.service.marketing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.emm.yixun.common.model.HaveReceiveRefundInfo;
import com.emm.yixun.common.model.NeedReceiveRefundInfo;
import com.emm.yixun.common.model.enums.DocTypeEnum;
import com.emm.yixun.common.utils.DateStyle;
import com.emm.yixun.common.utils.DateUtils;

/**
 * ClassName:NeedReceicerefundExportServiceImpl <br/>
 * Date:     2017年11月9日 下午1:51:21 <br/>
 * @author   Administrator
 * @version  
 * @since    JDK 1.6
 * @see 	 
 */
@Service
public class NeedReceicerefundExportServiceImpl implements NeedReceicerefundExportService {

	@Override
	public List<Map<String, String>> returnFieldNeedReceiveRefund(List<NeedReceiveRefundInfo> list, String[] head,String docType) {
		List<Map<String, String>> listMap = new ArrayList<Map<String,String>>();
		for (int i=0;i<list.size();i++) {
			NeedReceiveRefundInfo refund = list.get(i);
			Map<String, String> map = new HashMap<String, String>();
			map.put(head[0]+"_"+i, refund.getCustomer_name());//客户姓名
			map.put(head[1]+"_"+i, refund.getCombined_name());
			map.put(head[2]+"_"+i, StringUtils.isEmpty(refund.getCalculatArea())?"-":refund.getCalculatArea());
			map.put(head[3]+"_"+i, refund.getPrice()==null?"-":refund.getPrice().toString());
			map.put(head[4]+"_"+i, refund.getTotalPrice()==null?"-":refund.getTotalPrice().toString());
			map.put(head[5]+"_"+i, refund.getRelationType());
			map.put(head[6]+"_"+i, refund.getTotalReceivablesAmount()==null?"-":refund.getTotalReceivablesAmount().toString());
			if(docType.equals(DocTypeEnum.COLLECTION.getNo())){
				map.put(head[7]+"_"+i, refund.getReceivablesDate()==null?"-":DateUtils.DateToString(refund.getReceivablesDate(), DateStyle.YYYY_MM_DD.getValue()));
				map.put(head[8]+"_"+i, refund.getReceivedAmount()==null?"-":refund.getReceivedAmount().toString());
				map.put(head[9]+"_"+i, refund.getUncollectedAmount()==null?"-":refund.getUncollectedAmount().toString());
			}else{
				map.put(head[7]+"_"+i, refund.getCreateTime()==null?"-":DateUtils.DateToString(refund.getCreateTime(), DateStyle.YYYY_MM_DD.getValue()));
				map.put(head[8]+"_"+i, refund.getStatement_name());
				map.put(head[9]+"_"+i, refund.getRemark());
				
			}
			
			listMap.add(map);
		}
		return listMap;
	}

	@Override
	public List<Map<String, String>> returnFieldHaveReceiveRefund(List<HaveReceiveRefundInfo> list, String[] head) {
		List<Map<String, String>> listMap = new ArrayList<Map<String,String>>();
		for (int i=0;i<list.size();i++) {
			HaveReceiveRefundInfo refund = list.get(i);
			Map<String, String> map = new HashMap<String, String>();
			map.put(head[0]+"_"+i, refund.getCustomer_name());
			map.put(head[1]+"_"+i, refund.getCombined_name());
			map.put(head[2]+"_"+i, StringUtils.isEmpty(refund.getCalculatArea())?"-":refund.getCalculatArea());
			map.put(head[3]+"_"+i, refund.getPrice()==null?"-":refund.getPrice().toString());
			map.put(head[4]+"_"+i, refund.getTotalPrice()==null?"-":refund.getTotalPrice().toString());
			map.put(head[5]+"_"+i, refund.getRelationType());
			map.put(head[6]+"_"+i, refund.getBusinessType());
			map.put(head[7]+"_"+i, refund.getRealAmount()==null?"-":refund.getRealAmount().toString());
			map.put(head[8]+"_"+i, refund.getBillCode());
			map.put(head[9]+"_"+i, refund.getStatement());
			map.put(head[10]+"_"+i, refund.getBankAccount());
			map.put(head[11]+"_"+i, refund.getRemark());
			String headCheck = "";
			if(!StringUtils.isEmpty(refund.getReChecked())){
				if(refund.getReChecked().equals("0")){
					headCheck="未复核";
				}else{
					headCheck="已复核";
				}
			}
			map.put(head[12]+"_"+i, headCheck);
			map.put(head[13]+"_"+i, refund.getReceivablesDate()==null?"-":DateUtils.DateToString(refund.getReceivablesDate(), DateStyle.YYYY_MM_DD.getValue()));
			listMap.add(map);
		}
		return listMap;
	}

}

